#coding=utf-8
import socket
import argparse
socket.setdefaulttimeout(0.01)
def port_scan(taghost,tagport):
    """ 这是一个例子程序 """

    try:
        s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
        s.connect((taghost,tagport))
        print '[+] %d/tcp open'% tagport
        try:
            s.send('AAAAAAAA\r\n')
            results=s.recv(1024)
            print '[+]'+str(results)
        except:
            print "[-]没有接收到banner信息"
    except:
        pass
    finally:
        s.close()


if __name__ == '__main__':
    parser=argparse.ArgumentParser(description="这是我的第一个工具")
    parser.add_argument("-t","--taghost",help="输入扫描的目标ip")
    args=parser.parse_args()
    if args.taghost:
        for i in [21,22,23,139,443,445,80,8080,1389]:
            port_scan(args.taghost,i)
    else:
        print parser.format_help()


